package com.test.noahphan;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class Alarm extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_alarm);
		final ArrayList<String> arrWork = new ArrayList<String>();
		final ArrayAdapter<String> arrAdapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, arrWork);
		final EditText edtHour = (EditText) findViewById(R.id.edtHour);
		final EditText edtMin = (EditText) findViewById(R.id.edtMin);
		final EditText edtWork = (EditText) findViewById(R.id.edtWork);
		final ListView lvWork = (ListView) findViewById(R.id.lvWork);
		lvWork.setAdapter(arrAdapter);
		Button btnAdd = (Button) findViewById(R.id.btnAddWork);
		btnAdd.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				String wrk = edtWork.getText().toString() + ": "
						+ edtHour.getText().toString() + " - "
						+ edtMin.getText().toString();
				arrWork.add(wrk);
				arrAdapter.notifyDataSetChanged();
				edtHour.setText("");
				edtMin.setText("");
				edtWork.setText("");
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.alarm, menu);
		return true;
	}

}
